package me.ingxin.android.sample.lego.interceptor

import android.content.Context
import androidx.appcompat.app.AlertDialog
import me.ingxin.android.router.annotaions.Interceptor
import me.ingxin.android.router.route.RouteInterceptor
import me.ingxin.android.router.route.Request
import me.ingxin.android.sample.lego.utils.logD

/**
 * Created by ingxin on 2022/4/27
 */
@Interceptor("test4", priority = 20)
class Test4Interceptor : RouteInterceptor {
    override fun handle(context: Context, request: Request, dispatcher: RouteInterceptor.Dispatcher) {
        "Test4Interceptor开始执行".logD()
        AlertDialog.Builder(context)
            .setTitle("提示")
            .setMessage("${request.uri.path}指定的拦截器Test4Interceptor正在拦截")
            .setPositiveButton("拦截") { _, _ ->
                dispatcher.interrupt()
            }
            .setNegativeButton("不拦截") { _, _ ->
                dispatcher.continueRun()
            }
            .create()
            .show()
    }
}